<?php
session_start();
?>
<html>
  <?php include('include.header.html'); ?>
  <body class="bodycliente">

    <div id="contacto" align="center">
      <form id="frm_bp" name="frm_bp" method="post">
        <div id="DATO_HIDE" style="display:none" style="width:90%">
          <div id="DATO"></div>
        </div>
        <table class="marco">
          <tr>
            <td height="10%" colspan='2'>
              <?php include('menu_clientes.php'); ?>
            </td>
          </tr>
          <tr>
            <td align="center" valign="top">
              <table class="cuadross" width="500px">
                <tr>
                  <td>Contacto</td>
                </tr>
              </table>
              <br>

              <table class="formulario" width="500px">
                <tr>
                  <td>Nombre y Apellido</td>
                  <td><input type="text" id="nombre" name="nombre" class="input validate['required','nodigit','length[1,20]']"></td>
                </tr>
                <tr>
                  <td>em@ail</td>
                  <td><input type="text" id="mail" name="mail" class="input validate['required','email']"></td>
                </tr>
                <tr>
                  <td>Comentarios</td>
                  <td><textarea id="comentarios" name="comentarios" class="input validate['length[0,1000]']"></textarea></td>
                </tr>
                <tr>
                  <td colspan="2" align="center">
                    <input type="submit" id="submit" name="submit" value="Enviar">
                  </td>
                </tr>
              </table>
            </td>
            <td class="banner">
              <table class="banner" celpadding="2">
                <tr>
                  <td><a href="/oportunidades.php"><img src='images/banner/oportunidades.jpg' width="200px" border="0"/></a></td>
                </tr>
                <tr>
                  <td></td>
                </tr>
                <tr>
                  <td><a href="/destacados.php"><img src='images/banner/destacados.jpg' width="200px"/></a></td>
                </tr>
              </table> 
            </td>
          </tr>
          <tr>
            <td height="10%" colspan='2' valign="bottom" align="center">
              <?php include('footer.php'); ?>
            </td>
          </tr>
        </table>
      </form>
    </div>
  </body>
  <?php include('include.footer.html'); ?>
  <script>
    ///////////////////////////////
    var myCheck;
    myCheck = new FormCheck('frm_bp', {
      submit:false,
      display:{
        errorsLocation : 1,
        indicateErrors : 2,
        keepFocusOnError : 0,
        closeTipsButton : 1,
        checkValueIfEmpty:1,                
        showErrors : 1
      }
    });		 
 
    $('frm_bp').addEvent('submit',function(ev){
      var IsValid;
      IsValid=myCheck.isFormValid();                                                                          
      if (IsValid){ 
            
        Ejecutor();
      }    
    });
    ///////////////////////////////

    function Ejecutor(){        
      window.addEvent('domready', function() {      	       
        var req = new Request.JSON({
          method: 'POST',
          url: 'ajax/ajax_mail_contacto.php', 
          data: $('frm_bp'),                
          noCache:true,                     
          onRequest: function(){
            $('submit').disabled = true;
            $('DATO_HIDE').show();
            $('DATO').innerHTML = 'Procesando ...'; 
          },
          onComplete: function(){
            setTimeout(function(){
              $('DATO_HIDE').fade('out').get('tween').chain(function() {
                $('DATO_HIDE').hide();
                $('DATO_HIDE').fade('in');                                                         
              });
            },2000);                                                                                                                                                                                                              
          },             
          onSuccess: function(response){
            switch(parseInt(response.RESULT)){
              case 0:
                $('DATO').innerHTML = "Operaci&oacute;n exitosa";  
                //                window.location='/registro-clientes-listo';
                break;
              case 1:
                $('DATO').innerHTML = response.ERROR;
                $('submit').disabled = false;
                break;
            }
          }
        }).post();        
      });
    }
  </script>
</html>
